﻿/*
   Copyright 2012 University of Southampton

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace uk.ac.soton.ses
{
    [RunInstaller(true)]
    public class Installer:System.Configuration.Install.Installer
    {
        //We don't have anything to do in Install. Note that you must still call the custom Install method from the MSI project in order to 
        //get an InstallState file that can be passed to the Commit function that we override below

        /// <summary>
        /// Overridden Commit method in order to ask the user for information regarding the installation
        /// </summary>
        /// <param name="savedState">Passed in automatically containing options state we might need regarding the install. It can be modified.</param>
        public override void Commit(System.Collections.IDictionary savedState)
        {
            //Call the overridden method
            base.Commit(savedState);

            //Load passed parameters
            string launchWizardCheckBox = this.Context.Parameters["launchwizard"];

            //Only ask the user for further configuration options if they asked for the wizard to be displayed
            bool launchWizardChecked = (launchWizardCheckBox == "1");
            if (launchWizardChecked)
            {
                DataCollectionForm dcDialog = new DataCollectionForm();
                dcDialog.ShowDialog();
            }
        }
    }
}
